window.Sun={
		version:'1.0.0-snapshot',
		init: function(){
			if(!window.CE)
				window.CE=Sun.CE;
			if(!window.$package)
				window.$package=Sun.$package;
		},
		$package : function(pkg){
			if(!(typeof pkg =='string')){
				this.Log.error('package error ！');
				return;
			}
			var w=window;
			var cs=pkg.split('.');
			for(var i=0;i<cs.length;i++){
				if(!w[cs[i]])w[cs[i]]={};
				w=w[cs[i]];
			}
		},
		getClass : function(className){
			if(!className)return null;
			var w=window;
			var cns=className.split('.');
			for(var i=0;i<cns.length;i++){
				w=w[cns[i]];
			}
			return w;
		},
		initClass : function(className){
			var clz=className;
			if(clz && typeof clz=='string'){
				clz=Sun.getClass(className);
			}
			var obj=new clz();
			if(typeof(obj.init)=='function'){
				obj.init();
			}
			return obj;
		},
		Log : {
			isDebugEnabled:true,
			debug:function(s){
				this.log('[DEBUG]'+s);
			},
			info:function(s){
				this.log('[INFO]'+s);
			},
			error:function(s){
				this.log('[ERROR]'+s);
			}
		},
		invoke : function(url,data,callback){
			data=Sun.toJson(data);
			$.ajax({ url: url,
			     type:"post",
			     contentType : 'application/json', 
			     data:data,
			     success: function(result){
			    	 if(callback)callback(result);
		         },
		         error : function(error){
		        	 if(callback)callback(error);
		         }
		     });
		},
		toJson : function(obj){
			if(typeof obj=='string')return obj;
			var data=JSON.stringify(obj);
			return data;
		},
		toStr : function(json){
			var obj=JSON.parse(json);
			return obj;
		},
		CE : function(type,id,className){
			var demo=document.createElement(type||'div');
			if(id)demo.id=id;
			if(className)demo.className=className;
			return demo;
		},
		UUID : function(){
			var s = [];
			var hexDigits = "0123456789abcdefjhigklmnopqrstuvwxyz";
			for (var i = 0; i < 36; i++) {
			s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
			}
			s[14] = "4";
			s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); 
			s[8] = s[13] = s[18] = s[23] = "-";
			var uuid = s.join("");
			uuid=uuid.replace(/-/g,"");
			uuid=uuid.toUpperCase();
			return uuid;
		}
};
Sun.init();